<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" >
    <meta http-equiv="X-UA-Compatible" content="IE=11,IE=10,IE=9,IE=8" >
    <meta name="baidu-site-verification" content="dIcXMeY8Ya" />
    
    <title>Xposed 入坑篇 | Zed的个人 博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" >
    <meta name="keywords" content="Zed, 前端, Web, Android,逆向" >
    <meta name="description" content="Zed个人小站" >

    
    <link rel="alternative" href="/atom.xml" title="Zed的个人 博客" type="application/atom+xml" >
    
    
    <link rel="shortcut icon" href="/favicon.ico" >
    
    <link rel="stylesheet" href="/css/style.css">
    <!--[if lt IE 9]>
    <script src="/js/html5.js"></script>
    <![endif]-->
    
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "//hm.baidu.com/hm.js?fd459238242776d173cdc64918fb32f2";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>


</head>

<body class="home">
    <!--[if lt IE 9]>
    <div class="browsehappy">
        当前网页 <strong>不支持</strong>
        你正在使用的浏览器. 为了正常的访问, 请 <a href="http://browsehappy.com/">升级你的浏览器</a>.
    </div>
    <![endif]-->

    <!-- 博客头部 -->
    <header class="header">
    <section class="container header-main">
        <div class="logo">
            <a href="/">
                <div class="cover">
                    <span class="name">Zed的个人 博客</span>
                    <span class="description">个人博客</span>
                </div>
            </a>
        </div>
        <div class="dropnav icon-paragraph-justify" id="JELON__btnDropNav"></div>
        <ul class="menu hidden" id="JELON__menu">
            
            <li rel="/2018/06/29/xposed-first-lesson/index.html" class="item ">
                <a href="/" title="首页" class="icon-home">&nbsp;首页</a>
            </li>
            
            <li rel="/2018/06/29/xposed-first-lesson/index.html" class="item ">
                <a href="/lab/" title="实验室" class="icon-lab">&nbsp;实验室</a>
            </li>
            
            <li rel="/2018/06/29/xposed-first-lesson/index.html" class="item ">
                <a href="/about/" title="关于" class="icon-about">&nbsp;关于</a>
            </li>
            
            <li rel="/2018/06/29/xposed-first-lesson/index.html" class="item ">
                <a href="/comment/" title="留言" class="icon-comment">&nbsp;留言</a>
            </li>
            
        </ul>
        <div class="profile clearfix">
            <div class="feeds fl">
                
                
                <p class="links">
                    
                        <a href="https://github.com/kingzd" target="_blank">Github</a>
                        |
                    
                </p>
                <p class="sns">
                    
                        <a href="https://bbs.pediy.com/user-804033.htm" class="sinaweibo" target="_blank"><b>■</b> 看雪论坛</a>
                    
					<!-- 注释掉微信公众号的显示 -->
					<!--
                    <a href="javascript: void(0);" class="wechat">
                        <b>■</b>
                        公众号
                        <span class="popover">
                            <img src="/img/wechat_mp.jpg" width="120" height="120" alt="我的微信订阅号">
                            <i class="arrow"></i>
                        </span>
                    </a>
					-->
                </p>
                
            </div>
            <div class="avatar fr">
                <img src="/img/804033.png" alt="avatar" title="Jelon" >
            </div>
        </div>
    </section>
</header>


    <!-- 博客正文 -->
    <div class="container body clearfix">
        <section class="content">
            <div class="content-main widget">
                <!-- 文章页 -->
<!-- 文章 -->
<article class="post article">
    <header class="text-center">
        <h3 class="post-title"><span>Xposed 入坑篇</span></h3>
    </header>
    <p class="post-meta text-center">
        Zed 发表于
        <time datetime="2018-06-29T00:58:03.484Z">2018-06-29</time>
    </p>
    <div class="post-content">
        <p>近些日子，受到高人指点，突然想入坑学习学习 Xposed 于是乎在网上搜集一些入门例子 其中遇到了些小问题 记录下来 可能帮助同样遇到此问题的你<br><a href="https://www.52pojie.cn/thread-690818-1-1.html" target="_blank" rel="noopener">https://www.52pojie.cn/thread-690818-1-1.html</a><br><a href="http://www.freebuf.com/articles/web/156944.html" target="_blank" rel="noopener">http://www.freebuf.com/articles/web/156944.html</a><br><a href="https://www.jianshu.com/p/8fbf9e88eb54" target="_blank" rel="noopener">https://www.jianshu.com/p/8fbf9e88eb54</a> （<a href="https://www.jianshu.com/u/348b77e56202" target="_blank" rel="noopener">@WrBug</a>）<br><a href="https://www.52pojie.cn/thread-533120-1-1.html" target="_blank" rel="noopener">https://www.52pojie.cn/thread-533120-1-1.html</a><br>深受启发，于是乎想自己按照教程来写写。同时感谢以上几位大佬的教程</p>
<p>首先我安装了比较新的<a href="https://share.weiyun.com/57vAGwz" target="_blank" rel="noopener">XposedInstaller_3.1.5.apk</a><br>安装成功后如下图<br><img src="https://upload-images.jianshu.io/upload_images/5223850-f13695c22e04c29e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480" alt="device-2018-04-12-101001.png"></p>
<p>接下来开始敲代码了 美滋滋(皮一下很开心) 上一张整个工程的图</p>
<p><img src="https://upload-images.jianshu.io/upload_images/5223850-16221197238999ea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="QQ截图20180412102021.png"></p>
<p>以下是Test和Tutorial的代码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">package com.zed.xposed.demo;</span><br><span class="line"></span><br><span class="line">import de.robv.android.xposed.IXposedHookLoadPackage;</span><br><span class="line">import de.robv.android.xposed.XposedBridge;</span><br><span class="line">import de.robv.android.xposed.callbacks.XC_LoadPackage;</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * Created by zed on 2018/4/11.</span><br><span class="line"> */</span><br><span class="line"></span><br><span class="line">public class Test implements IXposedHookLoadPackage &#123;</span><br><span class="line">    @Override</span><br><span class="line">    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable &#123;</span><br><span class="line">        XposedBridge.log(&quot;Loaded Test app: &quot; + lpparam.packageName);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>因为我在学习kotlin 所以后面应该会有两个版本代码<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">package com.zed.xposed.demo</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line"> * Created by zed on 2018/4/11.</span><br><span class="line"> */</span><br><span class="line">import de.robv.android.xposed.IXposedHookLoadPackage;</span><br><span class="line">import de.robv.android.xposed.XposedBridge;</span><br><span class="line">import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;</span><br><span class="line"></span><br><span class="line">open class Tutorial : IXposedHookLoadPackage &#123;</span><br><span class="line">    override fun handleLoadPackage(lpparam: LoadPackageParam?) &#123;</span><br><span class="line">        XposedBridge.log(&quot;Loaded app: &quot; + lpparam?.packageName);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>新建xposed_init的文本文档 里面只用声明下你的两个类文件 包名+类名<br>com.zed.xposed.demo.Tutorial<br>com.zed.xposed.demo.Test</p>
<p>最后是清单文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span><br><span class="line">&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;</span><br><span class="line">    package=&quot;com.zed.xposed.demo&quot;&gt;</span><br><span class="line"></span><br><span class="line">    &lt;application</span><br><span class="line">        android:allowBackup=&quot;true&quot;</span><br><span class="line">        android:icon=&quot;@mipmap/ic_launcher&quot;</span><br><span class="line">        android:label=&quot;@string/app_name&quot;</span><br><span class="line">        android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;</span><br><span class="line">        android:supportsRtl=&quot;true&quot;</span><br><span class="line">        android:theme=&quot;@style/AppTheme&quot;&gt;</span><br><span class="line">        &lt;meta-data</span><br><span class="line">            android:name=&quot;xposedmodule&quot;</span><br><span class="line">            android:value=&quot;true&quot; /&gt;</span><br><span class="line">        &lt;meta-data</span><br><span class="line">            android:name=&quot;xposeddescription&quot;</span><br><span class="line">            android:value=&quot;Hook log test&quot; /&gt;</span><br><span class="line">        &lt;meta-data</span><br><span class="line">            android:name=&quot;xposedminversion&quot;</span><br><span class="line">            android:value=&quot;82&quot; /&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        &lt;activity android:name=&quot;.MainActivity&quot;&gt;</span><br><span class="line">            &lt;intent-filter&gt;</span><br><span class="line">                &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;</span><br><span class="line"></span><br><span class="line">                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;</span><br><span class="line">            &lt;/intent-filter&gt;</span><br><span class="line">        &lt;/activity&gt;</span><br><span class="line">    &lt;/application&gt;</span><br><span class="line"></span><br><span class="line">&lt;/manifest&gt;</span><br></pre></td></tr></table></figure></p>
<p>build.gradle配置<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">dependencies &#123;</span><br><span class="line">    compile &apos;de.robv.android.xposed:api:82&apos;</span><br><span class="line">    compile &apos;de.robv.android.xposed:api:82:sources&apos;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>一切都在美好的方向了 build一下安装 重启后 打开了之后</p>
<p><img src="https://upload-images.jianshu.io/upload_images/5223850-05839017c53a4de0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480" alt="QQ截图20180412102953.png"></p>
<p>？？？ What Fuck (me is 逗比)</p>
<h1 id="Android-Studio-Gradle-based"><a href="#Android-Studio-Gradle-based" class="headerlink" title="Android Studio (Gradle-based)"></a>Android Studio (Gradle-based)</h1><p>The Xposed Framework API is published on Bintray/jCenter: <a href="https://bintray.com/rovo89/de.robv.android.xposed/api" target="_blank" rel="noopener">https://bintray.com/rovo89/de.robv.android.xposed/api</a><br>That makes it easy to reference it by simply adding a Gradle dependency in your <code>app/build.gradle</code>:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">repositories &#123;</span><br><span class="line">    jcenter();</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">dependencies &#123;</span><br><span class="line">    provided &apos;de.robv.android.xposed:api:82&apos;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><strong>It is very important that you use <code>provided</code> instead of <code>compile</code>!</strong> The latter would include the API classes in your APK, which can cause issues especially on Android 4.x. Using <code>provided</code> just makes the API classes usable from your module, but there will only be references to them in the APK. The actual implementation will be <em>provided</em> when the user installs the Xposed Framework.</p>
<p>In most cases, the <code>repositories</code> block already exists, and there are usually some dependencies already. In that case, you just need to add the <code>provided</code> line to the existing <code>dependencies</code> block.</p>
<p>There is also documentation available for the API (see below). Unfortunately, I didn’t find any good way to enable automatic download of the API sources, except using <em>both</em> of these lines:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">provided &apos;de.robv.android.xposed:api:82&apos;</span><br><span class="line">provided &apos;de.robv.android.xposed:api:82:sources&apos;</span><br></pre></td></tr></table></figure>
<p>The way Gradle caches the files, Android Studio will set up the second jar as source for the first one automatically. Better recommendations are welcome!</p>
<p>Please make sure to <strong>disable Instant Run</strong> (<code>File -&gt; Settings -&gt; Build, Execution, Deployment -&gt; Instant Run</code>), otherwise your classes aren’t included directly in the APK, but loaded via a stub application which Xposed can’t handle.</p>
<p>赶紧把手捂住脸 偷偷修改下app/build.gradle下的依赖引用<br>还有个错误情况就是 你只引用了<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">compile &apos;de.robv.android.xposed:api:82&apos;</span><br></pre></td></tr></table></figure></p>
<p>也会出现一个错误 日志内容如下<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): -----------------</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): Starting Xposed version 89, compiled for SDK 21</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): Device: Custom Phone - 5.0.0 - API 21 - 768x1280 (unknown), Android version 5.0 (SDK 21)</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): ROM: vbox86p-userdebug 5.0 LRX21M 17 test-keys</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): Build fingerprint: generic/vbox86p/vbox86p:5.0/LRX21M/17:userdebug/test-keys</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): Platform: x86, 32-bit binary, system server: yes</span><br><span class="line">04-11 22:36:23.839 I/Xposed  ( 3386): SELinux enabled: no, enforcing: no</span><br><span class="line">04-11 22:36:26.060 I/Xposed  ( 3386): -----------------</span><br><span class="line">04-11 22:36:26.060 I/Xposed  ( 3386): Added Xposed (/system/framework/XposedBridge.jar) to CLASSPATH</span><br><span class="line">04-11 22:36:26.084 I/Xposed  ( 3386): Detected ART runtime</span><br><span class="line">04-11 22:36:26.089 I/Xposed  ( 3386): Found Xposed class &apos;de/robv/android/xposed/XposedBridge&apos;, now initializing</span><br><span class="line">04-11 22:36:26.158 I/Xposed  ( 3386): Loading modules from /data/app/com.zed.xposed.demo-1/base.apk</span><br><span class="line">04-11 22:36:26.158 E/Xposed  ( 3386):   Cannot load module:</span><br><span class="line">04-11 22:36:26.158 E/Xposed  ( 3386):   The Xposed API classes are compiled into the module&apos;s APK.</span><br><span class="line">04-11 22:36:26.158 E/Xposed  ( 3386):   This may cause strange issues and must be fixed by the module developer.</span><br><span class="line">04-11 22:36:26.158 E/Xposed  ( 3386):   For details, see: http://api.xposed.info/using.html</span><br></pre></td></tr></table></figure></p>
<p>说了那么多废话了 总结一下就是 如果你没有正常出现以下界面，请多多注意是不是你的依赖jar没有配置好 不要急<br><img src="https://upload-images.jianshu.io/upload_images/5223850-a1d1560fd1eef8dd.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/480" alt="QQ截图20180412104010.png"></p>
<p>以上是一个入门级 新手的入坑记录</p>

    </div>
    <p class="post-meta">
        <span class="post-cat">分类：
            <a class="cat-link" href="/categories/Xposed/">Xposed</a>
        </span>
        <span class="post-tags">
            标签：
            
    
        <a href="/tags/Xposed/" title="Xposed">Xposed</a>
    

        </span>
    </p>
</article>
<!-- 分享按钮 -->

  <div class="article-share clearfix text-center">
    <div class="share-area">
      <span class="share-txt">分享到：</span>
      <a href="javascript: window.open('http://service.weibo.com/share/share.php?url=' + encodeURIComponent(location.href) + '&title=' + document.title + '&language=zh_cn');" class="share-icon weibo"></a>
      <a href="javascript: alert('请复制链接到微信并发送');" class="share-icon wechat"></a>
      <a href="javascript: window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + encodeURIComponent(location.href) + '&title=' + document.title);" class="share-icon qqzone"></a>
      <a href="javascript: window.open('http://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(location.href) + '&desc=Jelon个人博客&title=' + document.title + '&callback=' + encodeURIComponent(location.href));" class="share-icon qq"></a>
      <a href="javascript: window.open('http://shuo.douban.com/!service/share?href=' + encodeURIComponent(location.href) + '&name=' + document.title + '&text=' + document.title);" class="share-icon douban"></a>
    </div>
  </div>


<!-- 上一篇/下一篇 -->

<!-- 文章评论 -->

  <script src="/js/comment.js"></script>
  <div id="comments" class="comment">
    <!--
    <div class="sign-bar">
      GitHub 已登录!
      <span class="sign-link">登出</span>
    </div>
    <section class="box">
      <div class="com-avatar"><img src="/img/jelon.jpg" alt="avatar"></div>
      <div class="com-text">
        <div class="main">
          <textarea class="text-area-edited show" placeholder="欢迎评论！"></textarea>
          <div class="text-area-preview"></div>
        </div>
        <div class="switch">
          <div class="switch-item on">编辑</div>
          <div class="switch-item">预览</div>
        </div>
        <div class="button">提交</div>
      </div>
    </section>
    <section class="tips">注：评论支持 markdown 语法！</section>
    <section class="list-wrap">
      <ul class="list">
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">张德龙</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like liked">已赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">333333</div>
          </div>
        </li>
        <li>
          <div class="user-avatar">
            <a href="/">
              <img src="/img/jelon.jpg" alt="user-avatar">
            </a>
          </div>
          <div class="user-comment">
            <div class="user-comment-header">
              <span class="post-name">刘德华</span>
              <span class="post-time">2017年12月12日</span>
              <span class="like">点赞</span>
              <span class="like-num">2</span>
            </div>
            <div class="user-comment-body">vvvvv</div>
          </div>
        </li>
      </ul>
      <div class="page-nav">
        <a href="javascript: void(0);" class="item">1</a>
        <a href="javascript: void(0);" class="item">2</a>
        <a href="javascript: void(0);" class="item current">3</a>
      </div>
    </section>
    -->
  </div>
  <script>
  JELON.Comment({
    container: 'comments',
    label: 'xposed-first-lesson' || '2018/06/29/xposed-first-lesson/',
    owner: 'kingzd',
    repo: 'repo',
    clientId: 'f56fec6294e9b3dafbb4',
    clientSecret: 'd2c7d3358239afe9c108647c36918bb0d7ab2dfa'
  });
  </script>


            </div>

        </section>
        <!-- 侧栏部分 -->
<aside class="sidebar">
    <section class="widget">
        <h3 class="widget-hd"><strong>文章分类</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
    <li>
        <a href="/categories/Xposed/">Xposed</a>
        <span class="badge">(1)</span>
    </li>
    
</ul>
    </section>

    
    <section class="widget">
        <h3 class="widget-hd"><strong>热门标签</strong></h3>
        <!-- 文章标签 -->
<div class="widget-bd tag-wrap">
  
    <a class="tag-item" href="/tags/Xposed/" title="Xposed">Xposed (1)</a>
  
</div>
    </section>
    

    

    
    <!-- 友情链接 -->
    <section class="widget">
        <h3 class="widget-hd"><strong>友情链接</strong></h3>
        <!-- 文章分类 -->
<ul class="widget-bd">
    
        <li>
            <a href="https://bbs.pediy.com/user-804033.htm" target="_blank" title="技术博客">看雪论坛</a>
        </li>
    
</ul>
    </section>
    
</aside>
<!-- / 侧栏部分 -->
    </div>

    <!-- 博客底部 -->
    <footer class="footer">
    &copy;
    
        2016-2018
    

    <a href="/">Zed Loves You</a>
</footer>
<div class="back-to-top" id="JELON__backToTop" title="返回顶部">返回顶部</div>

    <!--博客js脚本 -->
    <!-- 这里放网站js脚本 -->
<script src="/js/main.js"></script>
</body>
</html>